package com.IOFileTest;

import org.junit.Test;

import java.io.File;

public class Directory_ {
    public static void main(String[] args) {

    }
    @Test
    public void m1(){
        File file = new File("d:\\test01.doc");
        if (file.exists()){
            if (file.delete()){
                System.out.println("删除成功");
            }else {
                System.out.println("删除失败");
            }
        }else {
            System.out.println("不纯在该文件");
        }
    }
    @Test
    public void m2(){
        String filePath = "d:\\demo2";
        File file = new File(filePath);
        if (file.exists()){
            if (file.delete()){
                System.out.println("删除成功");
            }else {
                System.out.println("删除失败");
            }
        }else {
            System.out.println("该文件不存在");
        }
    }

    @Test
    public void m3(){
        String filePath = "d:\\a\\b\\c";
        File file = new File(filePath);
        if (file.exists()){
            System.out.println("文件存在");
        }else {
            if (file.mkdirs()){
                System.out.println("创建成功");
            }else {
                System.out.println("创建失败");
            }
        }
    }
}
